home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1408 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  4.6 KB

  1. Path: news.mcs.net!usenet
  2. From: The Last Raptor <raptor@mcs.net>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Two strange C problems.
  5. Date: Sat, 13 Jan 1996 12:52:20 -0600
  6. Organization: J.C. Technical Services
  7. Message-ID: <30F7FF64.6148@mcs.net>
  8. References: <DKuJHw.Dsu@rci.ripco.com>
  9. NNTP-Posting-Host: raptor-1.isdn.mcs.net
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0b5 (Win95; I)
  14.  
  15. Martin Ambuhl wrote:
  16. > cs102238@lux.latrobe.edu.au (Gregary John Boyles )
  17. > in <4cojb2$qog@lugb.latrobe.edu.au> wrote:
  18. > > I have two C problems.
  19. > And what are they?  You have problems, all right.  Are they C problems?
  20. > Maybe, but there is no way to tell when your code is all dos-isms.  Just
  21. > to compile this junk required me to add the following at the beginning.
  22. > If it doesn't look like it does what you expect, no big deal.  Your
  23. > non-standard functions, structs, and macros can be defined any way one
  24. > wants, as long as there are no syntax problems as a result.  The
  25. > semantics are completely undefined.
  26. > /* BEGINNING prologue */
  27. > #include <stdio.h>
  28. > typedef struct {
  29. >     short screenheight, screenwidth;
  30. > }   text_info;
  31. > typedef struct { /* warning: no members */
  32. > }  *nodetypeptr;
  33. > #define initialize(x)
  34. > #define cputs   puts
  35. > #define cprintf   printf
  36. > #define maxstring BUFSIZ
  37. > #define removelineends(x,y)
  38. > #define add(x,y,z)
  39. > #define gettextinfo(x)
  40. > #define getcolors(a,b,c,d)
  41. > #define _setcursortype(x)
  42. > #define clrscr()
  43. > #define textcolor(x)
  44. > #define textbackground(x)
  45. > #define gotoxy(x,y)
  46. > #define writescreenfull(a,b,c,d,e,f,g);
  47. > #define setpos(x,y)
  48. > #define displayhelp(x,y,z)
  49. > #define readstring(a,b,c,d,e)
  50. > #define searchstring()
  51. > #define empty(x)    0
  52. > #define remove(y)               /* note: remove is a reserved
  53. >                                  * identifier (see stdio) */
  54. > #define getch() getchar()
  55. > #define window(a,b,c,d)
  56. > char line[maxstring], bottomline[maxstring];
  57. > enum {
  58. >     LIGHTGRAY, BLACK, _NOCURSOR, _NORMCURSOR, space, escape, up, down,
  59. >     pageup, pagedown, left, right, end_, home, search, help, nul
  60. > }; /* note: _Nxxx are reserved identifiers */
  61. > /* END prologue */
  62. > [snip - line after line of M$dog-isms]
  63. > >This program should exit such that the screen is clear with the DOS
  64. > >prompt in the upper left corner, ...
  65. > Why should it?  C doesn't even have such a concept as "screen".  If
  66. > your implementation provides such functions, learn to use them or call
  67. > their technical support, or pay someone to debug your crap.
  68. > >..., but no, it exits with a short line
  69. > >of text on the first line and then the DOS prompt on the next
  70. > >line.I never(or rarely) have these sort of problems with Pascal so
  71. > >why do they continuously crop up with C.
  72. > Your problems have NOTHING to do with C.  If you can't tell the
  73. > difference, then go back to whatever you have confused with Pascal.
  74. > >
  75. > >
  76. > > PROBLEM 2 :
  77. > >
  78. > > const escape=27; const cr=13; const bs=8;
  79. > >
  80. > > while (ch!=cr) { . . . }
  81. > >
  82. > > while (ch!=escape) { . . . }
  83. > >
  84. > > If I replace the 27 with \27' or the 13 with '\13' then these loops
  85. > > don't work i.e. an infinite loop results. WHY?
  86. > Clever.  You have worked out that octal and decimal are not the same.
  87. > Just a hint:
  88. > \13 == 11
  89. > \15 == 13
  90. > \27 == 23
  91. > \33 == 27
  92. > > Also if I want to do somthing like this : puts("\24 \25"); which
  93. > > should print the up and down arrows on the screen (ASCII 24 and
  94. > > 25), but no, it prints some other ASCII characters. As far as I can
  95. > > tell C has its own unique character table, at least for the control
  96. > > characters. WHY?
  97. > The IBM-extended character set (_not_ ASCII) defines the Up arrow and
  98. > Down arrow as \30 == 24 and \31 == 25 (\24 == 20 is a paragraph sign.
  99. > \25 == 21 is a section sign).  This has nothing to do with C (except for
  100. > the use of \ooo for octal chars), and nothing to do with ASCII.  The
  101. > world is not defined by your PC-toy.
  102. > > Sometimes I wonder whether some one needs to go back an rewrite the
  103. > > damn language so that it works sensibly and predictably like Pascal
  104. > > can be relied upon to do.
  105. > Learning how to read would be a hell of a lot more useful.  The only
  106. > thing here which does not work sensibly and predictably is your brain.
  107. > --
  108. > * Martin Ambuhl       net: mambuhl@ripco.com
  109. > * Chicago, IL (USA)That was so nice of you Martin........
  110. Try a little patince next time or do you prefer being an ahole.
  111. -- 
  112. J.C. Technical Services                 The Last Raptor 
  113. CNA\CNE on call 24 hours a day.
  114. Novell, SNA, Banyan and Windows NT.
  115. Your complete network solution provider.
  116.